/* 8911106 302933981 Ofri Keidar */

/******************************************************************************
* Student Name: Ofri Keidar
* Exercise Name: Ex6
* File Description: Class MyInventoryException's interface, derived from runtime_error.
* 	                The class is abstract and used as common interface for the
* 				    exceptions that Inventory's method can raise. Its derived
* 				    classes use MyInventoryException's int-to-string and string-to-char*
* 				    conversion methods in order to create the error message
* 				    returned by runtime_error's what()
******************************************************************************/


#ifndef MYINVENTORYEXCEPTION_H_
#define MYINVENTORYEXCEPTION_H_
#include <stdexcept>
#include <iostream>
#include <string>
using namespace std;
#define DEFLT_MSG "" // default message to be set as runtime_error()'s argument
#define RADIX 10 // radix of numbers to be converted to string

class MyInventoryException: public runtime_error  {
protected:

	char* m_errorMsg; // pointer to error message string

	/***************************************************************************************
	* function name: string intToString(const int intToCnvrt) const
	* The Input: Int to be converted
	* The output: String that its content is given number
	* The Function operation: Converts given number to string and returns result
	***************************************************************************************/
	string intToString(const int intToCnvrt) const;

	/***************************************************************************************
	* function name: char* stringToCharPtr(const string strToCnvrt)
	* The Input: String to be converted to char* array
	* The output: Char* array that points at a string with given string's content
	* The Function operation: Creates a char* with given string's content and returns it
	***************************************************************************************/
	char* stringToCharPtr(const string strToCnvrt);

	/***************************************************************************************
	* function name: MyInventoryException(const MyInventoryException& excptToCopy)
	* The Input: MyInventoryException object to be copied
	* The output: None
	* The Function operation: Creates a new MyInventoryException object that its m_errorMsg
	* 					      attribute points at NULL, since its error message will be
	* 					      set when calling to what()
	***************************************************************************************/
	MyInventoryException(const MyInventoryException& excptToCopy);

public:
	/***************************************************************************************
	* function name: MyInventoryException()
	* The Input: None
	* The output: None
	* The Function operation: Creates a new MyInventoryException object
	***************************************************************************************/
	MyInventoryException();

	/***************************************************************************************
	* function name: virtual ~MyInventoryException() throw() = 0
	* The Input: None
	* The output: None
	* The Function operation: Destructs MyInventoryException object
	***************************************************************************************/
	virtual ~MyInventoryException() throw() = 0;
};


#endif
